<?php
/* vim: set expandtab tabstop=4 shiftwidth=4: */
// +----------------------------------------------------------------------+
// | PHP version 5                                                        |
// +----------------------------------------------------------------------+
// | Copyright (c) 1997-2004 The PHP Group                                |
// +----------------------------------------------------------------------+
// | This source file is subject to version 3.0 of the PHP license,       |
// | that is bundled with this package in the file LICENSE, and is        |
// | available through the world-wide-web at the following url:           |
// | http://www.php.net/license/3_0.txt.                                  |
// | If you did not receive a copy of the PHP license and are unable to   |
// | obtain it through the world-wide-web, please send a note to          |
// | license@php.net so we can mail you a copy immediately.               |
// +----------------------------------------------------------------------+
// | Authors: Original Author <author@example.com>                        |
// |          Your Name <you@example.com>                                 |
// +----------------------------------------------------------------------+
//
// $Id:$
#查询当前key的下一个key的键值

$a = array("Volvo" => "XC90", "BMW" => "X5", "Toyota" => "Highlander");
$keys = array_keys($a);
$a = array_search('Toyota', $keys) + 1;

echo "array的位置" . $a;

$cache_time = blockCacheTime('day');

echo "cache_time=" . $cache_time;

function blockCacheTime($cache_time = 900) {

	//缓存当天数据
	if ($cache_time === 'day') {
		$time_tomorrow = date("Y-m-d", strtotime("+1 day"));
		$time_tomorrow = strtotime($time_tomorrow);
		return $time_tomorrow - time();
	} else {
		return $cache_time;
	}

}
$k = 0;
for ($i = 1; $i <= 5; $i++) {
	$k++;
}

echo "kkkk=" . $k;
echo "<br><br>";

$num = 10;
$price = 14.51;
$total = 145.1;

$content = str_repeat(".", 10) . $num . "      " . $price . "       " . $total . "<BR>";

echo $content;
echo "<br><br>";
$str = "abc"; //str_pad($value,2,0,STR_PAD_LEFT);
$content = sprintf('%5s', $str) . $num . sprintf('%10s', $price) . sprintf('%10s', $total);
echo $content;
echo "<br><br>";

function getcharsP($c, $length) {
	return str_repeat($c, $length);
}

$date = '2008-02-29';
$a = checkDateFormat($date);
var_dump($a);

function checkDateFormat($date) {
	//匹配日期格式
	if (preg_match("/^([0-9]{4})-([0-9]{2})-([0-9]{2})$/", $date, $parts)) {
		//检测是否为日期
		var_dump($parts[2], $parts[3], $parts[1]);
		if (checkdate($parts[2], $parts[3], $parts[1])) {
			return true;
		} else {
			return false;
		}

	} else {
		return false;
	}

}
?>

